package nowcoder.nc52;

import java.util.*;


public class Solution {
    public static void main(String[] args) {
        System.out.println((int)'(');
        System.out.println((int)')');
        System.out.println((int)'[');
        System.out.println((int)']');
        System.out.println((int)'{');
        System.out.println((int)'}');
    }
    /**
     * 
     * @param s string字符串 
     * @return bool布尔型
     */
    public boolean isValid (String s) {
        // write code here
        Stack<Character> stack = new Stack<Character>();
        for(char c:s.toCharArray()){
            if(c =='('||c =='['||c =='{')
                stack.push(c);
            else{
                if (stack.isEmpty()) return false;
                Character c2=stack.pop();
                if (c-c2>2) return false;
            }

        }
        return stack.empty();
    }
}